package com.zy.openchat;

import android.graphics.drawable.Drawable;

import com.blankj.utilcode.util.LogUtils;
import com.ja.openchat.BuildConfig;
import com.lqr.emoji.EmojiManager;
import com.zy.openchat.core.model.user.UserInfo;

import java.io.File;
import java.util.Arrays;
import java.util.List;

public class Constants {


    //log
    public static void Loge(String tag, String msg) {
        if (App.isAppDebugMode(App.getInstanse())) {
            LogUtils.e(tag, msg);
        }
    }

    public static void Logd(String tag, String msg) {
        if (App.isAppDebugMode(App.getInstanse())) {
            LogUtils.d(tag, msg);
        }
    }

    public static String authUserRootPath() {
        return App.getInstanse().getFilesDir().getAbsolutePath() + File.separator + "users" + File.separator;
    }

    //本地图片路径
    public static String userImagePath() {
        return App.getInstanse().getFilesDir().getAbsolutePath() + File.separator
                + "files" + File.separator
                + (UserInfo.getUserInfo().id + "") + File.separator
                + "images" + File.separator;
    }

    //本地语音路径
    public static String userAudioPath() {
        return App.getInstanse().getFilesDir().getAbsolutePath() + File.separator
                + "files" + File.separator
                + (UserInfo.getUserInfo().id + "") + File.separator
                + "audios" + File.separator;
    }

    //本地视频路径
    public static String userVideoPath() {
        return App.getInstanse().getFilesDir().getAbsolutePath() + File.separator
                + "files" + File.separator
                + (UserInfo.getUserInfo().id + "") + File.separator
                + "videos" + File.separator;
    }

    //本地文件路径
    public static String userFilePath() {
        return App.getInstanse().getFilesDir().getAbsolutePath() + File.separator
                + "files" + File.separator
                + (UserInfo.getUserInfo().id + "") + File.separator
                + "files" + File.separator;
    }

    /**
     * 允许撤回多长时间内的消息，不能长于服务端相关配置，单位是秒
     */
    public static int RECALL_TIME_LIMIT = 60;

    /**
     * 允许重新编辑多长时间内的撤回消息，单位是秒
     */
    public static int RECALL_REEDIT_TIME_LIMIT = 60;

    /**
     * 语音消息最长时长，单位是秒
     */
    public static int DEFAULT_MAX_AUDIO_RECORD_TIME_SECOND = 60;

    public static int MEDIA_MAX_WIDTH = 600;

    public static final String DEFAULT_RED_PACKET_TITLE = "恭喜发财, 大吉大利";

    //群公告固定前缀
    public static final String GROUP_NOTICE_PREFIX = "@所有人 ";


    //声网appid
    public static String getAgoraAppId() {
        return BuildConfig.AgoraAppId;
    }


    public static final String KHostPrivacyAddress = BuildConfig.KHostPrivacyAddress;


    public static final String KHostUserAgreementAddress = BuildConfig.KHostUserAgreementAddress;


    public static final String KHostShareAddress = BuildConfig.KHostShareAddress;


    public static final String KHostAddress = BuildConfig.KHostAddress;


    public static final String KHostEReport = BuildConfig.KHostEReport;

    //密钥
    private static String getAesPassword() {
        return "GoChat_AES_WZY_2021";
    }

    public static final String AesPassword = getAesPassword();


    public static final String GdWebMapAppId = BuildConfig.GdWebMapAppId;

    public static final int MAX_CIRCLE_IMAGE_COUNT = 9;
    public static final int MAX_GROUP_MEMBER_SHOW_COUNT = 15;

    public static final String GROUP_SHARE_LINK_PRE_TEXT = "t.me/joinchat/";

    public static final int PAGE_COUNT = 20;

    public static final String DM_TEXT = "dm";
    public static final int DM_TEXT_LENGTH = DM_TEXT.length();

    public static final int NETWORK_FOR_IMAGE = 0;
    public static final int NETWORK_FOR_VIDEO = 1;
    public static final int NETWORK_FOR_FILE = 2;

    public static final String SPU_FOR_ENTER_KEY_FOR_SEND = "spu_enter_key_for_send";

    public static final String SPU_FOR_NOTIFICATION_SHOW = "spu_notification_show";
    public static final String SPU_FOR_NOTIFICATION_VOICE = "spu_notification_voice";
    public static final String SPU_FOR_NOTIFICATION_VIBRATE = "spu_notification_vibrate";

    public static final String SPU_FOR_USE_MOBILE_NETWORK = "spu_use_mobile_network";
    public static final String SPU_FOR_USE_WIFI_NETWORK = "spu_use_wifi_network";

    public static final String SPU_FOR_AUTO_SAVE_IMAGE = "spu_auto_save_image";
    public static final String SPU_FOR_AUTO_SAVE_EDIT_IMAGE = "spu_auto_save_edit_image";
    public static final String SPU_FOR_AUTO_PLAY_GIF = "spu_auto_play_gif";

    public static final String SPU_FOR_CACHE_SAVE_TIME = "spu_cache_save_time";

    public static final String SPU_FOR_CACHE_LAST_CLEAN_TIME = "spu_cache_last_clean_time";

    public static final String SPU_FOR_MAX_CACHE_OCCUPY = "spu_max_cache_occupy";


    public static final int CACHE_FOR_3_DAYS = 0;
    public static final int CACHE_FOR_1_WEEK = 1;
    public static final int CACHE_FOR_1_MONTH = 2;
    public static final int CACHE_FOR_PERMANENT = 3;


    public static final int Notify_User_Name_Type = 666;
    public static final int Notify_Message_Reaction = 667;
    public static final int Max_Message_Reaction_Count = 10;

    public static final List<Integer> messageEmojiIndexs = Arrays.asList(new Integer[]{Integer.decode("0x1f44d"),Integer.decode("0x1f44e"),Integer.decode("0x1f60d"),Integer.decode("0x1f44f")});

    public static Drawable getReactionDrawableById(int reactionId){
        int index = reactionId-1;
        if(index<0){
            index = 0;
        }else if(index>=messageEmojiIndexs.size()){
            index = messageEmojiIndexs.size()-1;
        }
        return EmojiManager.getDrawable(App.getInstanse(),messageEmojiIndexs.get(index));
    }

    public static final int CIRCLE_TOPIC_MAX_WORD_COUNT = 10;
}
